<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
        <script src="js/time.js?"></script>
        <script language='javascript'>
            function change_table(string)
            {
                var table_type=string.value;
                if(table_type==='type_object'||table_type==='dynamic_type_object')
                {
                    document.getElementById('table_id').style.display='table-row';
                    $("#itemtypeid").remove();
                    str = "<input type='text' name='row[itemtypeid]' id='itemtypeid' size='25' class='autocomplete' table='"+table_type+"'/>";
                    $("#add_type").append(str);
                    autocomplete();
                }               
            }

          	//显示物品类型
        	function showobject()
        	{
        	
        		var material = $('#material_type').val();
        		//alert(tableenum);
        		//alert(i);
        		//判断选的模块名是否合法 之前是否已经选择过了？

        		var objList = <?=json_encode($objecttype)?>;
        		var strOption = '';
        		for(var one in objList[material])
        	    {
        	    	strOption += '<option value="'+one+'" >'+objList[material][one]['name']+'</option>';
        	    }
        		//alert('material = '+material+" stroption "+strOption); 
        		$('#itemtypeid').html(strOption);        		
        		
        	} 

        	//显示职业类型
        	function showoprofession()
        	{
        		var material = $('#material_type').val();
        		var objectid = $('#itemtypeid').val();
        		//alert('material:'+material+" objectid:"+objectid);
        		//alert(i);
        		//判断选的模块名是否合法 之前是否已经选择过了？

        		var objList = <?=json_encode($objecttype)?>;
        		var professionlist = <?=json_encode($professiontype)?>;
        		//alert(professionlist);
        		var strOption;
        		if( 10 == material)	//表示是装备
        		{
            		var p = objList[material][objectid]['profession'];
        			strOption='<input type="hidden" name="row[proffessionid]" value="'+p+'" />'
            			+professionlist[p];	
        		}else
        		{
        			strOption='<input type="hidden" name="row[proffessionid]" value="-1"/>'
            			+professionlist[-1];	//其它都是通用
        		}
        		//alert(' material = '+material+" objectid:"+objectid+" stroption "+strOption); 
        		$('#profession').html(strOption);

        		var icon = objList[material][objectid]['objecticon'];
        		$('#icon').val(icon);
        		
        		var defaultprise = objList[material][objectid]['buygold'];
        		$('#prise').val(defaultprise);

        		var objectname = objList[material][objectid]['name'];
        		$('#name').val(objectname);
        	} 
        </script>
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <form action="" method="POST" id="rowForm">
            <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
                <tr>
                    <td><?= translate('C_SELECT_AREA_TEXT') ?>:</td>
                    <td><?= $area_host ?></td>
                </tr>
                <tr>
                	<!--  
                    <td><?= translate('MALL_STOREGOODS_TABLES') ?></td>
                    <td><?= $tables ?></td>
                    -->

                    <td><?= translate('MALL_TREASUREBOXRATIO_MATERIAL_TYPE') ?></td>
                    <td>
                    	<select name="row[material_type]" id="material_type" onChange="showobject()">
                    	<option value="-1"><?= translate('PLASE_SELECT') ?></option>
						<?php  foreach ($materialtype as $key => $value) { ?>
							<option value="<?=$key ?>"><?=$value ?></option>
						<?php } ?>
						</select>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('MALL_TREASUREBOXRATIO_OBJECT_NAME') ?></td>
                    <td>
                    	<select name="row[itemtypeid]" id="itemtypeid" onChange="showoprofession()">
                    	<option value="-1"><?= translate('MALL_TREASUREBOXRATIO_PLEASE_SELECT_KIND') ?></option>
						</select>
                    </td>
                </tr>
                <tr>
                	 <td><?= translate('MALL_TREASUREBOXRATIO_PROFESSION') ?></td>
                    <td id = "profession">
                    	<?= translate('MALL_TREASUREBOXRATIO_PLEASE_SELECT_OBJECT') ?>
                    	<!--  
                    	<select name="row[profession]" id="profession">
						<?php  foreach ($professiontype as $key => $value) { ?>
							<option value="<?=$key ?>"><?=$value ?></option>
						<?php } ?>
						</select>
					 	-->
                    </td>
                    
                </tr>
                <!--  
                <tr>
                    <td><?= translate('MALL_STOREGOODS_DEFAULTPRISE')?>:</td>
                    <td id='defaultprise'>&nbsp;</td>
                </tr>
                -->
                <tr>
                    <td><?= translate('MALL_STOREGOODS_PRISE')?>:</td>
                    <td><input type="text" name="row[prise]" id="prise" size="25" disable='disabled'/></td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_HOTPRISE')?>:</td>
                    <td><input type="text" name="row[hotprise]" id="hotprise" size="25" value="0"/><font color='red'><img src="images/!.gif">&nbsp;注：非热销默认填0</font></td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_SCOREPRISE')?>:</td>
                    <td><input type="text" name="row[scoreprise]" id="scoreprise" size="25" value='0'/><font color='red'><img src="images/!.gif">&nbsp;注：非积分默认填0</font></td>
                </tr>
                 <tr>
                    <td><?= translate('MALL_STOREGOODS_MOUNT')?>:</td>
                    <td><input type="text" name="row[mount]" id="mount" size="25" value='-1'/><font color='red'><img src="images/!.gif">&nbsp;注：无限制填-1</font></td>
                </tr>
                 <tr>
                    <td><?= translate('MALL_STOREGOODS_GLOBALMOUNT')?>:</td>
                    <td><input type="text" name="row[globalmount]" id="globalmount" size="25" value='-1'/><font color='red'><img src="images/!.gif">&nbsp;注：无限制填-1</font></td>
                </tr>
                 <tr>
                    <td><?= translate('MALL_STOREGOODS_BUYLIMIT')?>:</td>
                    <td><input type="text" name="row[buylimit]" id="buylimit" size="25"/></td>
                </tr> 
                <tr>
                    <td><?= translate('MALL_STOREGOODS_STARTTIME')?>:</td>
                    <td><input type="text" name="row[starttime]" id="starttime" size="25"  onclick="SelectDate(this,'yyyy-MM-dd hh:mm',0,10)"/></td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_DEADTIME')?>:</td>
                    <td><input type="text" name="row[deadtime]" id="deadtime" size="25"  onclick="SelectDate(this,'yyyy-MM-dd hh:mm',0,10)"/></td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_NAME')?>:</td>
                    <td><input type="text" name="row[name]" id="name" size="25"/></td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_HOTLIMIT')?>:</td>
                    <td><input type="radio" name="row[hotlimit]" id="hotlimit" size="25" value="1" checked/>是&nbsp;&nbsp;&nbsp;<input type="radio" name="row[hotlimit]" id="hotlimit" size="25" value="0"/>否</td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_ISREDUCE')?>:</td>
                    <td><input type="radio" name="row[isreduce]" id="isreduce" size="25" value="true" checked/>是&nbsp;&nbsp;&nbsp;<input type="radio" name="row[isreduce]" id="isreduce" size="25" value="false"/>否</td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_ISDOWN')?>:</td>
                    <td><input type="radio" name="row[isdown]" id="isdown" size="25" value="0" checked/>上架&nbsp;&nbsp;&nbsp;<input type="radio" name="row[isdown]" id="isdown" size="25" value="1"/>下架</td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_ICON')?>:</td>
                    <td><input type="text" name="row[icon]" id="icon" size="25"/></td>
                </tr>
                <tr>
                    <td><?= translate('MALL_STOREGOODS_CORNERICON')?>:</td>
                    <td><input type="text" name="row[cornericon]" id="cornericon" size="25"/></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" value="<?= translate('SUBMIT') ?>" id="submit" /> <input type="reset" value="<?= translate('RESET') ?>" id="reset" /></td>
                </tr>
            </table>
        </form>
        <script type="text/javascript">
            SG.init("core.form", function() {
                $.formValidator.initConfig({formid: "#rowForm", submitonce: true});
                $("#area_host").formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#tables").formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#itemtypeid").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#proffessionid").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#prise").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#hotprise").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#scoreprise").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#mount").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#globalmount").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#buylimit").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#deadtime").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#starttime").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#name").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#hotlimit").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
               // $("#isreduce").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#isdown").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#icon").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#cornericon").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
            });
        </script>
    </body>
</html>